Stripe setup future usage mismatch#3690
Conversation
|
Thanks for the contribution! It looks like @rvishwanathbhat is an internal user so signing the CLA is not required. However, we need to confirm this. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
| [customer, paymentConfig] | ||
| ) | ||
| // Stable key so we only re-init when SPM list actually changes. | ||
| const savedPaymentMethodsKey = useMemo( |
There was a problem hiding this comment.
If we can call this with [savedPaymentMethods] in the dependency array, then wouldn't that mean we can add savedPaymentMethods to the below useEffect where you added savedPaymentMethodsKey?
There was a problem hiding this comment.
savedPaymentMethods is an array, so whenever the array changes (even with customer/paymentConfig and no changes in the list of SPMs), the component reinits again.
But savedPaymentMethodsKey is a string, so when savedPaymentMethods gets a new reference, the useMemo for savedPaymentMethodsKey does run again, but gets the same string if SPMs remains unchanged. if previous and current string values are the same, it does not re run, unlike the array.
There was a problem hiding this comment.
Is this the only case in the app where an array is hashed like this to create a stable key? If yes, we're probably doing something else wrong.
There was a problem hiding this comment.
Yes, seems this is the only place. Finding it a bit tricky to refetch SPM even if the checkout component waits. I reverted these changes and created another WI to track this bug so that the stripe future use bug can be checked in first.
9980e57 to
a159589
Compare
| } from '@salesforce/retail-react-app/app/components/shared/ui' | ||
| import {useToast} from '@salesforce/retail-react-app/app/hooks/use-toast' | ||
| import {useShopperBasketsV2Mutation as useShopperBasketsMutation, useCustomerType} from '@salesforce/commerce-sdk-react' | ||
| import { |
There was a problem hiding this comment.
is this formatting change a lint fix or something? I assume we dont need to mess with one-click in general
There was a problem hiding this comment.
Yes, it was just a lint fix. Trying to reduce failing tests.
…/stripe-setup-future-usage-mismatch Stripe setup future usage mismatch
…/stripe-setup-future-usage-mismatch Stripe setup future usage mismatch
…/stripe-setup-future-usage-mismatch Stripe setup future usage mismatch
Send setupFutureUsage to the backend and set paymentIntent.setup_future_usage only when the user is registered and opts to save; otherwise omit it so the PI is created and confirmed without setup_future_usage, removing the mismatch.
Description
Types of Changes
Changes
How to Test-Drive This PR
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization